//
//  DefaultImageWithTextCellData.m
//  18Birdies
//
//  Created by CC on 2017/8/22.
//  Copyright © 2017年 Lc. All rights reserved.
//

#import "DefaultImageWithTextCell.h"
#import "DefaultImageWithTextCellData.h"
#import "LcFoundation.h"

@implementation DefaultImageWithTextCellData

+ (DefaultImageWithTextCellData*)cellDataWithImageName:(NSString*)imageName {
  LC_CHECK_NOT_NULL(imageName);
  DefaultImageWithTextCellData* cellData = [[self alloc] init];
  cellData.imageTopMargin = 60;
  cellData.textTopMargin = 30;
  cellData.textFont = [LcFont gr17];
  cellData.backgroundColor = LC_COLOR_BLACKGROUND_GRAY;
  cellData->_imageName = imageName;
  return cellData;
}

+ (DefaultImageWithTextCellData*)cellDataWithImageName:(NSString*)imageName defaultText:(NSString*)defaultText {
  DefaultImageWithTextCellData* cellData = [DefaultImageWithTextCellData cellDataWithImageName:imageName];
  cellData.text = defaultText;
  cellData.textFont = [LcFont gr17];
  return cellData;
}

- (Class)cellClazz {
  return DefaultImageWithTextCell.class;
}

- (NSString*)nibName {
  return @"DefaultImageWithTextCell";
}

- (void)refreshCell:(DefaultImageWithTextCell*)cell {
  [super refreshCell:cell];
  cell.backgroundColor = self.backgroundColor;
  cell.hintImageView.image = [UIImage imageNamed:self.imageName];
  if (self.text.length > 0) {
    cell.hintLabel.attributedText= nil;
    cell.hintLabel.text = self.text;
    [cell.hintLabel setLcFont:self.textFont];
  } else {
    cell.hintLabel.text = nil;
    cell.hintLabel.attributedText = self.attributedText;
  }
  cell.hintImageViewTopMargin.constant = self.imageTopMargin;
  cell.hintLabelTopMargin.constant = self.textTopMargin;
  [self setNeedRefreshCellHeight];
}

@end
